import java.util.Scanner;

public class newgame
{
	String codeword;
	char mychar;
	String Playername;
	Scanner eingabe = new Scanner(System.in);
	String charstring;
	char[] chararray = new char[100];
	int tries = 0;
	
	public boolean checkChar(char mychar)
	{
		int i;
		int check=0;
		for(i=0;i<100;i++)
		{
			if(chararray[i] == mychar)
				check++;
			else
			continue;
		}
		
		if(check>=1)
		return false;
		else
		return true;
	}
		
	public void addChar(char mychar, int tries)
	{
		this.chararray[tries] = mychar;
	}
		
	public void setPlayername(String playername)
	{
		this.Playername = playername;
	}
	
	public String getPlayername()
	{
		return this.Playername;
	}
	
	public void setChar(char mychar)
	{
		this.mychar = mychar;
	}
	
	public char getChar()
	{
		return this.mychar;
	}
	public void setcodeword(String codeword)
	{
		this.codeword = codeword.toLowerCase();
	}
	
	public String getcodeword()
	{
		return this.codeword;
	}
	
	public int compare(String eingabe)
	{
		return 1;
	}
	public void printMainMenu()
	{
		System.out.println("#########################");
		System.out.println("#####1.Admin-Section#####");
		System.out.println("#####2.Save Highscore####");
		System.out.println("#####3.Load Highscore####");
		System.out.println("#####4.Play The Game ####");
		System.out.println("#####5.Exit##############");
		System.out.println("#########################");
	}
	
	public void printAdminMenu()
	{
		System.out.println("##############################");
		System.out.println("#####1.Change Password########");
		System.out.println("#####2.Enter Codeword#########");
		System.out.println("#####3.Change your Playername#");
		System.out.println("#####4.Return to Mainmenu#####");
		System.out.println("##############################");
	}
	
	public void letsplay()
	{
		if(getcodeword() == null || getPlayername() == null)
				{
					System.out.println("Entweder wurde kein Playername oder kein codeword gesetzt");
					if (getcodeword() == null)
					{
						System.out.println("Setze nun dein Codeword!");
						setcodeword(eingabe.next());
					}
					if (getPlayername() == null)
					{
						System.out.println("Setze nun deinen Playernamen!");
						setPlayername(eingabe.next());
					}
					else
					System.out.println("Irgendwas lief schief!");
					
				}
				else
				{
					int lv=0,i=0,fehler=0,win=0,hit=0;
					// char[] mystr = getcodeword().toCharArray();
					// char[] ergebnis = getcodeword().toCharArray();	
					char[] mystr = getcodeword().toCharArray();
					char[] ergebnis = new char[getcodeword().length()];
					
					
					
					for(lv=0;lv<getcodeword().length();lv++)
					{
						ergebnis[lv] = '_';
					}
					do{
						// System.out.println("Und? welcher Buchstabe darfs sein?");
						do{
							System.out.println("Und? welcher Buchstabe darfs sein?");
							setChar((eingabe.next().toLowerCase()).charAt(0)); 
						if(!checkChar(mychar))
							System.out.println("Youve already chosen this Character, try another one!");
						else
						{
							addChar(getChar(),tries);
							tries++;
						}
						}while(checkChar(mychar));
						for (i=0;i<getcodeword().length();i++)
						{
							if(mystr[i] == getChar())
							{
								ergebnis[i] = mystr[i];
								hit++;
							}
							else
							continue;
						}
						if(hit >0)
						{
							win = win+hit;
							hit=0;
						}
						else
						{
							fehler++;
							switch (fehler){
												case 1:
								System.out.println("\n __\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n\"\"\"\n|\"|\n| |\n: :\n. .");
								break;
							case 2:
								System.out.println("\n _\n| |\n| | / /\n| |/ /\n| | /\n| |/\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n\"\"\"\n|\"|\n| |\n: :\n. .\n ");
								break;
							case 3:
								System.out.println("\n ___________________\n| ._________________|\n| | / /\n| |/ /\n| | /\n| |/\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n\"\"\"\n|\"|\n| |\n: :\n. .\n");
								break;
							case 4:
								System.out.println("\n ____________________\n| .__________________|\n| | / /\n| |/ /\n| | /\n| |/\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\n|\"|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\"|\n| |                  | |\n: :                  : :\n. .                  . .\n"); // created by Kais @ freitagsrunde . org
								break;
							case 5:
								System.out.println("\n  ___________.._______\n| .__________))______|\n| | / /      ||\n| |/ /       ||\n| | /        ||\n| |/         ||\n| |          ||\n| |          ||\n| |          ||\n| |          (\\__\n| |           `--'\n| |\n| |\n| |\n| |\n| |\n| |\n| |\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\n|\"|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\"|\n| |                  | |\n: :                  : :\n. .                  . .\n");
								break;
							case 6:
								System.out.println("\n" + "  ___________.._______\n"
										+ "| .__________))______|\n" + "| | / /      ||\n"
										+ "| |/ /       ||\n" + "| | /        ||    .-''.\n"
										+ "| |/         ||   /  _  \\\n"
										+ "| |          ||   |  `/,|\n"
										+ "| |          (\\\\_  \\`_.'\n"
										+ "| |           `- .-'--'.\n"
										+ "| |             /Y . . Y\\\n"
										+ "| |            // |   | \\\\\n"
										+ "| |           //  | . |  \\\\\n"
										+ "| |          ')   |   |   (`\n"
										+ "| |               ||'||\n" + "| |               || ||\n"
										+ "| |               || ||\n" + "| |               || ||\n"
										+ "| |              /_| |_\\\n"
										+ "\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\n"
										+ "|\"|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\"|\n"
										+ "| |                  | |\n"
										+ ": :                  : :\n"
										+ ". .                  . .\n    ");
								break;
							case 7:
								System.out.println("\n" + "  ___________.._______\n"
										+ "| .__________))______|\n" + "| | / /      ||\n"
										+ "| |/ /       ||\n" + "| | /        ||.-''.\n"
										+ "| |/         |/  _  \\\n" + "| |          ||  `/,|\n"
										+ "| |          (\\\\`_.'\n" + "| |         .-`--'.\n"
										+ "| |        /Y . . Y\\\n" + "| |       // |   | \\\n"
										+ "| |      //  | . |  \\\n" + "| |     ')   |   |   (`\n"
										+ "| |          ||'||\n" + "| |          || ||\n"
										+ "| |          || ||\n" + "| |          || ||\n"
										+ "| |         /_| |_\\\n"
										+ "\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\n"
										+ "|\"|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|\"|\n"
										+ "| |                  | |\n"
										+ ": :                  : :\n"
										+ ". .                  . .\n");
								break;
							case 8:
								System.out.println("\n" + "  ___________.._______\n"
										+ "| .__________))______|\n" + "| | / /      ||\n"
										+ "| |/ /       ||\n" + "| | /        ||.-''.\n"
										+ "| |/         |/  _  \\\n" + "| |          ||  `/,|\n"
										+ "| |          (\\\\`_.'\n" + "| |         .-`--'.\n"
										+ "| |        /Y . . Y\\\\\n" + "| |       // |   | \\\\\n"
										+ "| |      //  | . |  \\\\\n"
										+ "| |     ')   |   |   (`\n" + "| |          ||'||\n"
										+ "| |          || ||\n" + "| |          || ||\n"
										+ "| |          || ||\n" + "| |         / | | \\\n"
										+ "\"\"\"\"\"\"\"\"\"\"|_`-' `-' |\"\"\"|\n"
										+ "|\"|\"\"\"\"\"\"\"\\ \\       '\"|\"|\n"
										+ "| |        \\ \\        | |\n"
										+ ": :         \\ \\       : :\n"
										+ ". .          `'       . .\n\n\n\nYOU DIED!");
								break; }
						}
						
						System.out.println(ergebnis);									// Ausgabe korrekt
						System.out.println("\n");
						System.out.println("Your Tries:\t"+tries);						// Ausgabe korrekt
						System.out.println("You've already tried:");					// Aussgabe korrekt
						System.out.println(chararray);									// Ausgabe korrekt
						
						System.out.println(ergebnis + "\n");						// Ausgabe ist hier völlig falsch
						System.out.println("Your Tries:\t" + tries);					// Diese Ausgabe ist korrekt
						System.out.println("Youve already tried:\t" + chararray.toString()); // genauso hier
						
						}while(win <getcodeword().length() && fehler < 8);
						if(win == getcodeword().length())
						System.out.println("Congratz! You've won =)! Do you wanna Save the Highscore? Press 2!");
						for(i=0;i<getcodeword().length();i++)
							{
								chararray[i] = '_';
							}
						win = 0;
						tries = 0;
				}
	}
}